package com.zzy.controller;

import com.zzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Author: zhangzhenyu
 * @Date: 2021/1/20
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("register/{email}/{password}/{code}")
    public int register(@PathVariable String email, @PathVariable String password, @PathVariable String code){
        return userService.register(email,password,code);
    }

    @RequestMapping("isRegistered/{email}")
    public Boolean isRegistered(@PathVariable String email){
        return userService.isRegistered(email);
    }

    @RequestMapping("login/{email}/{password}")
    public String login(HttpServletResponse response, @PathVariable String email, @PathVariable String password){

        return userService.login(response,email,password);
    }

    @RequestMapping("info/{token}")
    public String info( @PathVariable String token){

        return userService.info(token);
    }
}
